﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IceDog.DNL.CSharp.DesignPattern.CommandPattern.StockMarket
{
    /// <summary>
    /// 经纪人
    /// </summary>
    public class Broker
    {
        private readonly List<IOrder> _orders;

        public Broker()
        {
            _orders=new List<IOrder>();
        }
        /// <summary>
        /// 添加指令
        /// </summary>
        /// <param name="order"></param>
        public void TakeOrder(IOrder order)
        {
            _orders.Add(order);
        }
        /// <summary>
        /// 执行命令
        /// </summary>
        public void ExecuteOrders()
        {
            _orders.ForEach(o=>o.Execute());
            _orders.Clear();
        }
    }
}
